// 用对象的特性给数组去重
const arr = [1, 22, 22, 55, 11, 22, 33, 54]

ArratStor(arr)
function ArratStor(arr) {
  let obj = {}
  arr.forEach((v) => {
    if (obj[arr[v]]) {
      obj[arr[v]]++
    } else {
      obj[arr[v]] = 1
    }
  })
  console.log(obj)
  return obj
}

//节流
function debounce(fn, paly) {
  let time
  return function () {
    clearTimeout(time)
    time = setTimeout(() => {
      fn.apply(this, arguments)
    }, paly)
  }
}
//防抖 时间
//时间戳版本
function throttling(timeout, fn) {
  let _playing = null
  return function () {
    let _arg = arguments
    if (_playing) {
      return
    }
    _playing = true
    setTimeout(() => {
      fn.apply(this, _arg)
      _playing = false
    }, timeout)
  }
}
